from ultralytics import YOLO
from ultralytics.utils import DEFAULT_CFG
import os
import sys

sys.path.insert(0, os.path.dirname(os.getcwd()))
os.environ['CUDA_VISIBLE_DEVICES'] = '1'
DEFAULT_CFG.save_dir= "/data/script/model"
def train():
    # 加载模型
    model = YOLO("yolov8n.pt")
    #epochs=300, batch=16,save_dir=
    #训练模型
    model.train(data="/data/script/img-layout.yaml", epochs=10, device=1,batch=16 ,save=True)
    metrics = model.val()  # 在验证集上评估模型性能

if __name__ == '__main__':
    train()
